<?php
require_once '../../include/common.inc.php';
require_once '../function.php';
if(stripos(auth_group($_SESSION['login_gid']),'users_admin')===false)exit("没有权限！");
$auth_rule_userdel=false;
if(stripos(auth_group($_SESSION['login_gid']),'users_del')!==false)$auth_rule_userdel=true;

switch($act){
	case "user_del":
		if(stripos(auth_group($_SESSION['login_gid']),'users_del')===false)exit("没有权限！");
		  if(is_array($id)){
                  user_del(implode(',',$id));
                }
		else{
                       user_del($id);
                }
		header("location:?gid=".$gid);
	break;
}

$query=$db->query("select id,title from {$tablepre}auth_group order by id desc");
while($row=$db->fetch_row($query)){
	$group.='<option value="'.$row[id].'">'.$row[title].'</option>';
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../assets/css/bs3/dpl-min.css" rel="stylesheet" type="text/css" />
<link href="../assets/css/bs3/bui-min.css" rel="stylesheet" type="text/css" />
<link href="../assets/css/page-min.css" rel="stylesheet" type="text/css" />
<!-- 下面的样式，仅是为了显示代码，而不应该在项目中使用-->
<link href="../assets/css/prettify.css" rel="stylesheet" type="text/css" />
<style type="text/css">
code { padding: 0px 4px; color: #d14; background-color: #f7f7f9; border: 1px solid #e1e1e8; }
</style>
<script>
Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
function ftime(time){
	if(time==null || time=='') {
		return '';
	}
	return new Date(time*1000).Format("yyyy-MM-dd hh:mm"); ;
}
function ftime2(time){
	if(time>(60*60*24)) return parseInt(time/(60*60*24))+"天";
	else if(time>(60*60))return parseInt(time/(60*60))+"小时";
	else if(time>60)return parseInt(time/60)+"分钟";
	else return parseInt(time)+"秒";
}
function ftime3(time){
	if(time==null || time=='') {
		return '';
	}
	return new Date(time*1000).Format("hh:mm"); ;
}
function sgid(id){
	var arr=new Array();
	if(isNaN(id)) return '';
	<?php
	$query=$db->query("select * from {$tablepre}auth_group order by id desc");
while($row=$db->fetch_row($query)){
	echo "arr['{$row[id]}']='$row[title]';";
	}
	?>
	return arr[id];
}
var cats = [];
var datas = [];
</script>
</head>
<body>
<div class="container"  style="">
<form  class="form-horizontal" action="" method="get">
    <form action="" method="POST" enctype="application/x-www-form-urlencoded"  class="form-horizontal" id="hd_list">
  <div style="color:red;">注意: 本在线时间统计每15分钟自动执行一次</div>
  <div class="row">
	<div id="canvas"></div>
  </div>
  <table class="table table-bordered table-hover definewidth m10">
    <thead>
      <tr style="font-weight:bold" >
        <td width="80" align="center" bgcolor="#FFFFFF">统计时间</td>
        <td width="40" align="center" bgcolor="#FFFFFF">在线人数</td>
        <td width="40" align="center" bgcolor="#FFFFFF">PC端</td>
        <td width="40" align="center" bgcolor="#FFFFFF">手机端</td>
      </tr>
    </thead>
<?php

$sql="select total, mobile, total-mobile as pc, time from {$tablepre}onlinestat order by time desc";

echo userlist(36, $sql,'
    <tr>
      <td><script>document.write(ftime({time}));cats.unshift(ftime3({time})); datas.unshift({total});</script></td>
      <td>{total}</td>
      <td>{pc}</td>
      <td>{mobile}</td>
    </tr>
')?>

  </table>
    </form>
    <ul class="breadcrumb">
    <li class="active"><?=$pagenav?>
    </li>
  </ul>
</div>
<script type="text/javascript" src="../assets/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="../assets/js/bui.js"></script>
<script type="text/javascript" src="../assets/js/config.js"></script>
<script type="text/javascript" src="../../upload/swfupload/swfupload.js"></script>
</body>
</html>
<script>
	BUI.use('bui/calendar', function (Calendar) {
		var datepicker = new Calendar.DatePicker({
			trigger: '.calendar',
			dateMask: 'yyyy-mm',
			autoRender: true
		});
	});
	BUI.use('common/page');
	BUI.use('bui/chart', function (Chart) {

		var chart = new Chart.Chart({
			render: '#canvas',
			width: $('#canvas').width(),
			height: 400,
			title: {
				text: '过去24小时在线人数趋势',
				'font-size': '16px'
			},
			subTitle: {
				text: ''
			},
			xAxis: {
				categories: cats
			},
			yAxis: {
				title: {
					text: ''
				},
				min: 0
			},
			tooltip: {
				shared: true
			},
			seriesOptions: {
				columnCfg: {}
			},
			series: [{
				name: '时间轴',
				data: datas
			}]
		});

		chart.render();
	});

</script>
